package cn.edu.wfit.modules.learn.controller.competitionmanagement;

import java.util.List;

import cn.edu.wfit.modules.learn.domain.WfitCompetitionTeamrecord;
import cn.edu.wfit.modules.learn.service.competitionmanagement.IWfitCompetitionTeamrecordService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.wfit.common.log.annotation.Log;
import cn.edu.wfit.common.log.enums.BusinessType;
import cn.edu.wfit.common.security.annotation.RequiresPermissions;
import cn.edu.wfit.common.core.web.controller.BaseController;
import cn.edu.wfit.common.core.web.domain.AjaxResult;
import cn.edu.wfit.common.core.utils.poi.ExcelUtil;
import cn.edu.wfit.common.core.web.page.TableDataInfo;

/**
 * 团队赛记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/teamrecord")
public class WfitCompetitionTeamrecordController extends BaseController
{
    @Autowired
    private IWfitCompetitionTeamrecordService wfitCompetitionTeamrecordService;

    /**
     * 查询团队赛记录列表
     */
    @RequiresPermissions("system:teamrecord:list")
    @GetMapping("/list")
    public TableDataInfo list(WfitCompetitionTeamrecord wfitCompetitionTeamrecord)
    {
        startPage();
        List<WfitCompetitionTeamrecord> list = wfitCompetitionTeamrecordService.selectWfitCompetitionTeamrecordList(wfitCompetitionTeamrecord);
        return getDataTable(list);
    }

    /**
     * 导出团队赛记录列表
     */
    @RequiresPermissions("system:teamrecord:export")
    @Log(title = "团队赛记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfitCompetitionTeamrecord wfitCompetitionTeamrecord)
    {
        List<WfitCompetitionTeamrecord> list = wfitCompetitionTeamrecordService.selectWfitCompetitionTeamrecordList(wfitCompetitionTeamrecord);
        ExcelUtil<WfitCompetitionTeamrecord> util = new ExcelUtil<WfitCompetitionTeamrecord>(WfitCompetitionTeamrecord.class);
        util.exportExcel(response, list, "团队赛记录数据");
    }

    /**
     * 获取团队赛记录详细信息
     */
    @RequiresPermissions("system:teamrecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wfitCompetitionTeamrecordService.selectWfitCompetitionTeamrecordById(id));
    }

    /**
     * 新增团队赛记录
     */
    @RequiresPermissions("system:teamrecord:add")
    @Log(title = "团队赛记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfitCompetitionTeamrecord wfitCompetitionTeamrecord)
    {
        return toAjax(wfitCompetitionTeamrecordService.insertWfitCompetitionTeamrecord(wfitCompetitionTeamrecord));
    }

    /**
     * 修改团队赛记录
     */
    @RequiresPermissions("system:teamrecord:edit")
    @Log(title = "团队赛记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfitCompetitionTeamrecord wfitCompetitionTeamrecord)
    {
        return toAjax(wfitCompetitionTeamrecordService.updateWfitCompetitionTeamrecord(wfitCompetitionTeamrecord));
    }

    /**
     * 删除团队赛记录
     */
    @RequiresPermissions("system:teamrecord:remove")
    @Log(title = "团队赛记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wfitCompetitionTeamrecordService.deleteWfitCompetitionTeamrecordByIds(ids));
    }
}
